package com.wza.designPattern.BuilderPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * <一句话功能简述>
 * <p>
 * <功能详细描述>
 *
 * @author weizhian
 * @version [版本号, 2018/11/20]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class Meal
{
    private List<Item> itemList = new ArrayList<>();

    public void addItem(Item item)
    {
        itemList.add(item);
    }

    public float getCost()
    {
        float sum = 0.0f;

        for (Item item : itemList)
        {
            sum += item.price();
        }

        return sum;
    }

    public void showItems()
    {
        for (Item item : itemList)
        {
            System.out.print("Item : " + item.name());
            System.out.print(", Packing : " + item.packing().pack());
            System.out.println(", Price : " + item.price());
        }
    }
}
